//
//  REAnimatedButton.swift
//  GoGlobalis
//
//  Created by goglobails on 2018/10/17.
//  Copyright © 2018年 Webkul. All rights reserved.
//

import UIKit

class REAnimatedButton: UIButton {

    lazy var indicatorView : UIActivityIndicatorView = {
        let view = UIActivityIndicatorView(activityIndicatorStyle: .gray)
        view.backgroundColor = UIColor.white
        view.tintColor = REHexRGB(0x0688e8)
        view.color = REHexRGB(0x0688e8)
        if self.imageView != nil {
            view.center = self.imageView!.center
        } else {
            view.center = self.center
        }
        self.addSubview(view)
        return view
    }()
    
    func startAnimating() {
        self.indicatorView.startAnimating()
        self.imageView?.isHidden = true
    }
    
    func stopAnimating() {
        self.indicatorView.stopAnimating()
        self.imageView?.isHidden = false
    }
}
